#include <iostream>
#include <nlohmann/json.hpp>  // 从本地 include 目录加载

using json = nlohmann::json;

int main() {
    // 创建一个 JSON 对象
    json data;
    data["message"] = "Hello from local nlohmann/json!";
    data["version"] = 1.0;
    data["tags"] = {"C++", "CMake", "JSON"};

    // 序列化为字符串（带缩进）
    std::cout << "序列化结果:\n"
              << data.dump(2) << "\n\n";

    // 反序列化示例
    std::string json_str = R"({"name": "Alice", "age": 30})";
    auto parsed = json::parse(json_str);
    std::cout << "反序列化结果:\n"
              << "Name: " << parsed["name"] << "\n"
              << "Age: " << parsed["age"] << "\n";

    return 0;
}